﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EuroManager.Domain.Simulator.Engine;
using NUnit.Framework;

namespace EuroManager.Domain.Simulator.Tests.Engine
{
    [TestFixture]
    public class TimerTests
    {
        [Test]
        public void ShouldNotInformWhenTimeNotPassed()
        {
            Timer timer = new Timer(5);

            TestHelper.Advance(4, timer);

            Assert.IsFalse(timer.HasPassed);
        }

        [Test]
        public void ShouldInformWhenTimePassed()
        {
            Timer timer = new Timer(5);

            TestHelper.Advance(6, timer);

            Assert.IsTrue(timer.HasPassed);
        }

        [Test]
        public void ShouldNotInformWhenTimeWithSaltNotPassed()
        {
            Timer timer = new Timer(5, -1.5f);

            TestHelper.Advance(6, timer);

            Assert.IsFalse(timer.HasPassed);
        }

        [Test]
        public void ShouldInformWhenTimeWithSaltPassed()
        {
            Timer timer = new Timer(5, 1.5f);

            TestHelper.Advance(6, timer);

            Assert.IsTrue(timer.HasPassed);
        }

        [Test]
        public void ShouldReset()
        {
            Timer timer = new Timer(5);

            TestHelper.Advance(6, timer);
            timer.Reset();
            TestHelper.Advance(4, timer);

            Assert.IsFalse(timer.HasPassed);
        }

        [Test]
        public void ShouldResetWithSalt()
        {
            Timer timer = new Timer(5);

            TestHelper.Advance(6, timer);
            timer.Reset(2);
            TestHelper.Advance(4, timer);

            Assert.IsTrue(timer.HasPassed);
        }

        [Test]
        public void ShouldReduce()
        {
            Timer timer = new Timer(5);

            TestHelper.Advance(6, timer);
            timer.Reduce();

            Assert.IsFalse(timer.HasPassed);
        }

        [Test]
        public void ShouldReduceWithSalt()
        {
            Timer timer = new Timer(5);

            TestHelper.Advance(6, timer);
            timer.Reduce(2);
            TestHelper.Advance(3, timer);

            Assert.IsTrue(timer.HasPassed);
        }
    }
}
